package com.snpic.appaw.module.third.api.deepOCR.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @author JiJun
 * @date 2025/9/27 17:39
 * @修改时间 2025/9/27 17:39
 * @description 易道博识DeepOCR
 */
@Data
@Schema(description = "第三方 - 身份证结构化识别V1 Response DTO")
public class IdCardRespDTO {

    @Schema(description = "错误码（0：正确，1：无法识别，2：图像格式错误）", example = "0")
    private Integer error_code;

    @Schema(description = "结果描述", example = "识别成功")
    private String description;

    @Schema(description = "唯一请求标识符（用于回溯问题）", example = "req_123456789")
    private String request_id;

    @Schema(description = "Base64编码的调试XML数据")
    private String dbg_xml;

    @Schema(description = "识别所用时间（毫秒）")
    private Integer recognize_time;

    @Schema(description = "旋转角度（0/90/180/270）")
    private String rotation;

    @Schema(description = "识别结果主体")
    private Result result;

    @Data
    @Schema(description = "识别结果详情")
    public static class Result {
        @Schema(description = "区分正反面（1：人像面，2：国徽面）")
        private Integer face;

        @Schema(description = "图像风险类型（0：无风险）")
        private Integer risk;

        @Schema(description = "身份证切割图（Base64字符串）")
        private String crop_img;

        @Schema(description = "大头照切割图（Base64字符串）")
        private String face_img;

        @Schema(description = "姓名识别结果")
        private FieldResult name;

        @Schema(description = "性别识别结果")
        private FieldResult gender;

        @Schema(description = "民族识别结果")
        private FieldResult nationality;

        @Schema(description = "身份证号码识别结果")
        private FieldResult idno;

        @Schema(description = "住址识别结果")
        private FieldResult address;

        @Schema(description = "出生日期识别结果")
        private FieldResult birthdate;

        @Schema(description = "有效期限识别结果")
        private FieldResult valid;

        @Schema(description = "签发机关识别结果")
        private FieldResult issued;
    }

    @Data
    @Schema(description = "字段识别结果详情")
    public static class FieldResult {
        @Schema(description = "字段中文含义", example = "姓名")
        private String chinese_key;

        @Schema(description = "识别结果（UTF-8格式）", example = "张三")
        private String words;

        @Schema(description = "可信度（0~1）", example = "0.98")
        private Float score;

        @Schema(description = "四个顶点坐标（格式：x1,y1,x2,y2,x3,y3,x4,y4）")
        private String quad;

        @Schema(description = "位置矩形框")
        private Position position;
    }

    @Data
    @Schema(description = "位置矩形框定义")
    public static class Position {
        @Schema(description = "距离左侧像素", example = "100")
        private Integer left;

        @Schema(description = "距离上侧像素", example = "200")
        private Integer top;

        @Schema(description = "右侧矩形框长度", example = "300")
        private Integer right;

        @Schema(description = "下侧矩形框长度", example = "400")
        private Integer bottom;
    }
}
